%% Print model files in reports
% by Jaromir Benes
% 
% In this m-file, we print a simple model file in a report. The report
% features (optional) syntax highlighting and currently assigned parameter
% values.

%% Clear Workspace

clear;
close all;
home;
irisrequired 8.20111003;

%% Load and parameterise Simple Model
%
% What model file we use in this exercise is largely irrelevant, so we
% refrain from commenting on the model itself; we simply load the model and
% assign some parameters.

m = model('3eqtn.model','linear=',true);

m.alp = 0.5;
m.sgm = 0.1;
m.bet = 0.99;
m.gam = 0.1;
m.xi = 0.55;
m.rho = 0.80;
m.kap = 4;
m.tau = 0;

%% Create Report with Model File Listings
%
% We produce three different looks of the model file:
%
% * with syntax colouring and current parameter values;
% * with syntax colouring but no parameter values;
% * with no syntax colouring and no parameter values.
%
% Comments on the code below:
%
% * <?default?> The standard use of |modelfile| is with three input
% arguments: a caption (which can include a title and a subtitle), a model
% file name, and a model object (from which the parameter values will be
% taken). The last input argument, i.e. the model object, can be omitted.
%
% * <?noparam?> You can print a model code without parameter values by
% either not supplying a model object at all, or by setting the option
% `'paramValues'` to false.

x = report.new();

caption = {'Model file report -- 3eqtn.model', ...
    'Syntax coloring, Parameter values'};
x.modelfile(caption,'3eqtn.model',m); %?default?

x.pagebreak();

caption = {'Model file report -- 3eqtn.model', ...
    'Syntax coloring, No parameter values'};
x.modelfile(caption,'3eqtn.model'); %?noparam?

x.pagebreak();

caption = {'Model file report -- 3eqtn.model', ...
    'No syntax coloring, No parameter values'};
x.modelfile(caption,'3eqtn.model','syntax=',false);

%% Publish Report to PDF
%
% Compile the report into a PDF named `'report_model_files.pdf'`. The
% `open` command to open the PDF <?open?> may not work on some systems.

x.publish('report_model_files.pdf');

open report_model_files.pdf; %?open?

%% Help on IRIS Functions Used in This File
%
% Use either `help` to display help in the command window, or `idoc`
% to display help in an HTML browser window.
%
%    help report
%    help report/new
%    help report/modelfile
%    help report/pagebreak
%    help report/pagebreak
%    help report/publish
%    help model
%    help model/model
%    help model/subsasgn

